package simpleFactory.order;

import simpleFactory.pizza.CheesePizza;
import simpleFactory.pizza.GreekPizza;
import simpleFactory.pizza.PepperPizza;
import simpleFactory.pizza.Pizza;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2023-03-07
 * Time: 21:08
 */

//简单工厂类
public class SimpleFactory {

    //思路
    //根据传来一个的类型 创建一个披萨 返回就ok
    public Pizza createPizza(String orderType){


        Pizza pizza = null;

        System.out.println("使用简单工厂模式");
        if (orderType.equals("greek")){
            pizza = new GreekPizza();
            //已经创建好披萨了 设置一个名字
            pizza.setName("希腊披萨");
        }else if (orderType.equals("cheese")){
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
            //增加了新的披萨 那么逻辑的判断也要新增一个
        }else if (orderType.equals("pepper")){
            pizza = new PepperPizza();
            pizza.setName("胡椒披萨");
        }

        return pizza;
    }
}
